﻿@using Models;
@{
    ViewBag.Title = "仓库查询";
}
@Html.ActionLink("创建", "Create")
@(Html.Telerik().Grid<WarehouseView>().Name("Warehouse").DataBinding(databinding => databinding.Ajax().Select("AjaxWarehouseIndex", "Warehouse"))
                .DataKeys(keys =>
                {
                    keys.Add(s => s.ID);
                })
                .Columns(c =>
                {
                    c.Bound(w => w.WarehouseName).Width(150);
                    c.Bound(w => w.TotalVolume).Width(150);
                    c.Bound(w => w.Area.AreaName).Width(100);
                    c.Bound(w => w.ID).Title("操作").ClientTemplate("<a href='/Warehouse/edit/" + "<#= ID #>'>编辑</a> | <a href='/Warehouse/details/" + "<#= ID #>'>详细</a> | <a href='/Warehouse/Charts/" + "<#= ID #>'>库存图表</a> |<a href='/Warehouse/delete/" + "<#= ID #>'>删除</a>");
                })
                .DetailView(details => details.ClientTemplate(
                    Html.Telerik().TabStrip().Name("TabStrip_<#= ID #>").SelectedIndex(0).Items(
                        items => {
                            items.Add().Text("库存详细").Content(
                                       Html.Telerik().Grid<StockView>().Name("StockView<#= ID #>")
                                            .Columns(columns =>
                                            {
                                                columns.Bound(s => s.StockName).Width(150);
                                                columns.Bound(s => s.CategoryName).Width(150);
                                                columns.Bound(s => s.QualityName).Width(140);
                                                columns.Bound(s => s.Volume).Width(200);
                                                columns.Bound(s => s.Description);
                                            })
                                            .DataBinding(dataBinding => dataBinding.Ajax().Select("AjaxStockIndex", "Warehouse", new { WarehouseID = "<#= ID #>" }))
                                            .Pageable().Sortable().Filterable().ToHtmlString()); 
                            items.Add().Text("库存对比").Content(
                                       Html.Telerik().Chart<StockView>().Name("StockViewChart").Title("仓储情况")
                                       .Legend(legend => legend
                                       .Position(ChartLegendPosition.Bottom)).Series(series =>
                                       {
                                           series.Pie("Percentage", "CategoryName")
                                               .Labels(labels => labels.Visible(true).Template("<#= Percentage #>%")
                                               .Align(ChartPieLabelsAlign.Circle)
                                               .Position(ChartPieLabelsPosition.Center))
                                               .StartAngle(180).Padding(0);
                                       }).DataBinding(dataBinding => dataBinding.Ajax().Select("AjaxStockChart", "Warehouse"))
                                       .Tooltip(tooltip => tooltip.Visible(true).Template("<#= Percentage #>%"))
                                       .HtmlAttributes(new { style = "width: 400px; height: 300px;" }).ToHtmlString()); 
                        }).ToHtmlString()))
                .Resizable(resizing => resizing.Columns(true))
                .Groupable()
                .Pageable(p => p.PageSize(20))
                .Sortable()
                .Filterable()
                .Scrollable(scrolling => scrolling.Height(350))
)
